from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from core.support import get_game
from core.game import Game
import logging

class Sea8HearHello(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        game = get_game()
        player = game.get_player()
        self.add_action(Use50Shades)
        self.add_action(UseMolotov)
        self.add_action(UseMirror)
        self.add_action(WaveArms)

    
    # return description of room.
    def get_description(self):
        return "Your fish feast was delectable and you fall into a deep sleep. The next morning you awake to a buzzing in your ears. The humming grows louder as you awake and suddenly you see a small helicopter on the horizon. But how to signal it?!?!!?!?! What do you have that could get their attention?"
    # return image of room
    def get_image(self):
        return 'sea8hearhelo_pic.jpg'

    def fiftyis_inuse(self):
            
            game = get_game()
            
            # is there a lit lamp in the room itself?
            
            # does the player have a lit lamp?
            player = game.get_player()
            if 'fiftyshadesonfire' in player.inventory:
                if player.inventory['fiftyshadesonfire'].inuse:
                    return True
                    
            # if we get here, the lamp is not lit
            return False

    def molotovis_inuse(self):
            
            game = get_game()
            
            # is there a lit lamp in the room itself?
            
            # does the player have a lit lamp?
            player = game.get_player()
            if 'molotov' in player.inventory:
                if player.inventory['molotov'].inuse:
                    return True
                    
            # if we get here, the lamp is not lit
            return False
    
    
    def mirroris_inuse(self):
                
            game = get_game()
                
            # is there a lit lamp in the room itself?
                
            # does the player have a lit lamp?
            player = game.get_player()
            logging.info("player inventory ---------------------")
            logging.info(player.inventory)
            if 'mirror' in player.inventory:
                if player.inventory['mirror'].inuse:
                    return True
                        
            # if we get here, the lamp is not lit
            return False        

class Sea8HearHelloHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Sea8HearHello

# define actions for this room

class UseMirror(Action):
    def __init__(self):
        Action.__init__(self, "UseMirror")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Signal with Mirror"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'sea9rescueattempt'

    def get_method(self):
        return "get"
    
    def is_enabled(self):
        
        if self.room.mirroris_inuse():
            return True
        else:
            return False

class UseMolotov(Action):
    def __init__(self):
        Action.__init__(self, "UseMolotov")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Throw the Molotov"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'sea9rescueattempt'
    
    def get_method(self):
        return "get"
    
    def is_enabled(self):
        
        if self.room.molotovis_inuse():
            return True
        else:
            return False

class Use50Shades(Action):
    def __init__(self):
        Action.__init__(self, "Use50Shades")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Wave 50 shades, ITS ENFUEGO"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'sea9rescueattempt'
    
    def get_method(self):
        return "get"
    
    def is_enabled(self):
        
        if self.room.fiftyis_inuse():
            return True
        else:
            return False
        
class WaveArms(Action):
    def __init__(self):
        Action.__init__(self, "WaveArms")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Wave arms and shout your guts out!"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'helosignalfaildeath'
    
    def get_method(self):
        return "get"